module App
    class IgnoredClientModel < Qt::StandardItemModel
        def initialize(list)
            super()

            setColumnCount 1
            setHeaderData(0, Qt::Horizontal, Qt::Variant.new("Client"))

            for client in list
                add(client)
            end
            all
        end

        def add(name)
            new_item = Qt::StandardItem.new(name)
            self.invisibleRootItem.appendRow [ new_item ]
            new_item
        end

        def del(indexes)
            indexes.each { |index|
                item = itemFromIndex(index)
                self.invisibleRootItem.remove_row(item.row)
            }
        end

        def ignored?(name)
            find_items(name).first
        end

        def all
            a = []
            0.upto(self.invisibleRootItem.row_count-1) { |row|
                a << item(row)
            }
            a
        end
    end
end
